import React from 'react'
import { useNavigate } from 'react-router-dom'

export default function Test1() {
  const navigate = useNavigate()
  return (
    <h3>
      Test1
      <button
        onClick={() => {
          navigate('/about', {
            replace: true, // 由默认的添加历史记录,改为替换历史记录
            state: { name: 'zs' },
          })
        }}
      >
        点击切换到about页面
      </button>
      <button
        onClick={() => {
          navigate(-2)
        }}
      >
        根据历史记录回退
      </button>
    </h3>
  )
}
